home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / Tool Chest / Development Platforms / MPW Related / MPW Interfaces / PInterfaces / Components.p < prev    next >
Encoding:
Text File  |  1993-09-17  |  8.8 KB  |  259 lines  |  [TEXT/MPS ]

  1. {************************************************************
  2.     Created: Wednesday, April 21, 1993
  3.     Components.p
  4.     Pascal Interface to the Macintosh Libraries
  5.     
  6.     Copyright Apple Computer, Inc. 1990-93
  7.     All rights reserved
  8. ************************************************************}
  9.  
  10.  
  11. {$IFC UNDEFINED UsingIncludes}
  12. {$SETC UsingIncludes := 0}
  13. {$ENDC}
  14.  
  15. {$IFC NOT UsingIncludes}
  16.  UNIT Components;
  17.  INTERFACE
  18. {$ENDC}
  19.  
  20. {$IFC UNDEFINED UsingComponents}
  21. {$SETC UsingComponents := 1}
  22.  
  23. {$I+}
  24. {$SETC ComponentsIncludes := UsingIncludes}
  25. {$SETC UsingIncludes := 1}
  26. {$IFC UNDEFINED UsingTypes}
  27. {$I $$Shell(PInterfaces)Types.p}
  28. {$ENDC}
  29. {$IFC UNDEFINED UsingTypes}
  30. {$I $$Shell(PInterfaces)Memory.p}
  31. {$ENDC}
  32. {$SETC UsingIncludes := ComponentsIncludes}
  33.  
  34. CONST
  35. gestaltComponentMgr = 'cpnt';
  36.  
  37. kAnyComponentType =            0;
  38. kAnyComponentSubType =         0;
  39. kAnyComponentManufacturer =    0;
  40. kAnyComponentFlagsMask =    0;
  41.  
  42. cmpWantsRegisterMessage = $80000000;
  43.  
  44. { Component Resource Extension flags }
  45.     componentDoAutoVersion = 1;
  46.     componentWantsUnregister = 2;
  47.     componentAutoVersionIncludeFlags = 4;
  48.  
  49. TYPE
  50. ComponentDescription = RECORD
  51.  componentType: OSType;                                { A unique 4-byte code indentifying the command set }
  52.  componentSubType: OSType;                            { Particular flavor of this instance }
  53.  componentManufacturer: OSType;                        { Vendor indentification }
  54.  componentFlags: LONGINT;                            { 8 each for Component,Type,SubType,Manuf/revision }
  55.  componentFlagsMask: LONGINT;                        { Mask for specifying which flags to consider in search, zero during registration }
  56.  END;
  57.  
  58. ResourceSpec = RECORD
  59.  resType: OSType;                                    { 4-byte code  }
  60.  resId: INTEGER;                                    {    }
  61.  END;
  62.  
  63. ComponentResourcePtr = ^ComponentResource;
  64. ComponentResourceHandle = ^ComponentResourcePtr;
  65. ComponentResource = RECORD
  66.  cd: ComponentDescription;                            { Registration parameters }
  67.  component: ResourceSpec;                            { resource where Component code is found }
  68.  componentName: ResourceSpec;                        { name string resource }
  69.  componentInfo: ResourceSpec;                        { info string resource }
  70.  componentIcon: ResourceSpec;                        { icon resource }
  71.  END;
  72.  
  73. ComponentResourceExtension = RECORD
  74.     componentVersion        :    LONGINT;            { version of Component }
  75.     componentRegisterFlags    :    LONGINT;            { flags for registration }
  76.     componentIconSuite        :    INTEGER;            { resource id of Icon Suite }
  77.     END;
  78.  
  79. Component = ^ComponentRecord;
  80. ComponentRecord = RECORD
  81.  data: ARRAY [0..0] OF LONGINT;
  82.  END;
  83.  
  84. ComponentInstance = ^ComponentInstanceRecord;
  85. ComponentInstanceRecord = RECORD
  86.  data: ARRAY [0..0] OF LONGINT;
  87.  END;
  88.  
  89. { Structure received by Component:  }
  90. ComponentParameters = PACKED RECORD
  91.  flags: CHAR;                                        { call modifiers: sync/async, deferred, immed, etc }
  92.  paramSize: CHAR;                                    { size in bytes of actual parameters passed to this call }
  93.  what: INTEGER;                                        { routine selector, negative for Component management calls }
  94.  params: ARRAY [0..0] OF LONGINT;                    { actual parameters for the indicated routine }
  95.  END;
  96.  
  97. ComponentResult = LONGINT;
  98.  
  99. ComponentRoutine = ProcPtr;
  100.  
  101. ComponentFunction = ProcPtr;
  102.  
  103.  
  104. {******************************************************
  105. * Required Component routines
  106. ******************************************************}
  107.  
  108. CONST
  109. kComponentOpenSelect = -1;                            { ComponentInstance for this open }
  110. kComponentCloseSelect = -2;                            { ComponentInstance for this close }
  111. kComponentCanDoSelect = -3;                            { selector # being queried }
  112. kComponentVersionSelect = -4;                        { no params }
  113. kComponentRegisterSelect = -5;                        { no params }
  114. kComponentTargetSelect = -6;                        { ComponentInstance for top of call chain }
  115. kComponentUnregisterSelect = -7;                    { no params }
  116.  
  117. { Set Default Component flags }
  118. defaultComponentIdentical = 0;
  119. defaultComponentAnyFlags = 1;
  120. defaultComponentAnyManufacturer = 2;
  121. defaultComponentAnySubType = 4;
  122. defaultComponentAnyFlagsAnyManufacturer = defaultComponentAnyFlags+defaultComponentAnyManufacturer;
  123. defaultComponentAnyFlagsAnyManufacturerAnySubType = defaultComponentAnyFlags+defaultComponentAnyManufacturer+defaultComponentAnySubType;
  124.  
  125. { errors from component manager & components }
  126. invalidComponentID = -3000;
  127. validInstancesExist = -3001;
  128. componentNotCaptured = -3002;
  129. componentDontRegister = -3003;
  130.  
  131. badComponentInstance = $80008001;
  132. badComponentSelector = $80008002;
  133.  
  134.  
  135. { *******************************************************
  136. *                                                     *
  137. *              APPLICATION LEVEL CALLS                *
  138. *                                                     *
  139. *******************************************************
  140. * Component Database Add, Delete, and Query Routines 
  141. *******************************************************
  142.  }
  143. FUNCTION RegisterComponent(cd: ComponentDescription;componentEntryPoint: ComponentRoutine;
  144.  global: INTEGER;componentName: Handle;componentInfo: Handle;componentIcon: Handle): Component;
  145.  INLINE $7001,$A82A;
  146. FUNCTION RegisterComponentResource(tr: ComponentResourceHandle;global: INTEGER): Component;
  147.  INLINE $7012,$A82A;
  148. FUNCTION UnregisterComponent(aComponent: Component): OSErr;
  149.  INLINE $7002,$A82A;
  150.  
  151. FUNCTION FindNextComponent(aComponent: Component;looking: ComponentDescription): Component;
  152.  INLINE $7004,$A82A;
  153. FUNCTION CountComponents(looking: ComponentDescription): LONGINT;
  154.  INLINE $7003,$A82A;
  155.  
  156. FUNCTION GetComponentInfo(aComponent: Component;VAR cd: ComponentDescription;
  157.  componentName: Handle;componentInfo: Handle;componentIcon: Handle): OSErr;
  158.  INLINE $7005,$A82A;
  159. FUNCTION GetComponentListModSeed: LONGINT;
  160.  INLINE $7006,$A82A;
  161.  
  162.  
  163. { *******************************************************
  164. * Component Instance Allocation and dispatch routines 
  165. *******************************************************
  166.  }
  167. FUNCTION OpenComponent(aComponent: Component): ComponentInstance;
  168.  INLINE $7007,$A82A;
  169. FUNCTION CloseComponent(aComponentInstance: ComponentInstance): OSErr;
  170.  INLINE $7008,$A82A;
  171.  
  172. FUNCTION GetComponentInstanceError(aComponentInstance: ComponentInstance): OSErr;
  173.  INLINE $700A,$A82A;
  174.  
  175.  
  176. {  direct calls to the Components  }
  177. FUNCTION ComponentFunctionImplemented(ci: ComponentInstance;ftnNumber: INTEGER): LONGINT;
  178.  INLINE $2F3C,$2,$FFFD,$7000,$A82A;
  179. FUNCTION GetComponentVersion(ci: ComponentInstance): LONGINT;
  180.  INLINE $2F3C,$0,$FFFC,$7000,$A82A;
  181. FUNCTION ComponentSetTarget(ci:ComponentInstance; target:ComponentInstance):LONGINT;
  182.  INLINE $2F3C,$4,$FFFA,$7000,$A82A;
  183.  
  184.  
  185. {****************************************************
  186. *                                                    *
  187. *               CALLS MADE BY Components             *
  188. *                                                    *
  189. ******************************************************}
  190.  
  191.  
  192. { *******************************************************
  193. * Component Management routines
  194. *******************************************************
  195.  }
  196. PROCEDURE SetComponentInstanceError(aComponentInstance: ComponentInstance;
  197.  theError: OSErr);
  198.  INLINE $700B,$A82A;
  199.  
  200. FUNCTION GetComponentRefcon(aComponent: Component): LONGINT;
  201.  INLINE $7010,$A82A;
  202. PROCEDURE SetComponentRefcon(aComponent: Component;theRefcon: LONGINT);
  203.  INLINE $7011,$A82A;
  204.  
  205. FUNCTION OpenComponentResFile(aComponent: Component): INTEGER;
  206.  INLINE $7015,$A82A;
  207. FUNCTION CloseComponentResFile(refnum: INTEGER): OSErr;
  208.  INLINE $7018,$A82A;
  209.  
  210.  
  211. { *******************************************************
  212. * Component Instance Management routines
  213. *******************************************************
  214.  }
  215. FUNCTION GetComponentInstanceStorage(aComponentInstance: ComponentInstance): Handle;
  216.  INLINE $700C,$A82A;
  217. PROCEDURE SetComponentInstanceStorage(aComponentInstance: ComponentInstance;
  218.  theStorage: Handle);
  219.  INLINE $700D,$A82A;
  220.  
  221. FUNCTION GetComponentInstanceA5(aComponentInstance: ComponentInstance): LONGINT;
  222.  INLINE $700E,$A82A;
  223. PROCEDURE SetComponentInstanceA5(aComponentInstance: ComponentInstance;
  224.  theA5: LONGINT);
  225.  INLINE $700F,$A82A;
  226.  
  227. FUNCTION CountComponentInstances(aComponent: Component): LONGINT;
  228.  INLINE $7013,$A82A;
  229.  
  230. {  useful helper routines for convenient method dispatching  }
  231. FUNCTION CallComponentFunction(params: ComponentParameters;func: ComponentFunction): LONGINT;
  232.  INLINE $70FF,$A82A;
  233. FUNCTION CallComponentFunctionWithStorage(storage: Handle;params: ComponentParameters;
  234.  func: ComponentFunction): LONGINT;
  235.  INLINE $70FF,$A82A;
  236. FUNCTION DelegateComponentCall(originalParams: ComponentParameters;
  237.  ci: ComponentInstance): LONGINT;
  238.  INLINE $7024,$A82A;
  239.  
  240. FUNCTION SetDefaultComponent(aComponent: Component;flags: INTEGER): OSErr;
  241.  INLINE $701E,$A82A;
  242. FUNCTION  OpenDefaultComponent(componentType: OSType; componentSubType: OSType ) : ComponentInstance;
  243.  INLINE $7021,$A82A;
  244. FUNCTION CaptureComponent(capturedComponent: Component;capturingComponent: Component): Component;
  245.  INLINE $701C,$A82A;
  246. FUNCTION UncaptureComponent(aComponent: Component): OSErr;
  247.  INLINE $701D,$A82A;
  248. FUNCTION RegisterComponentResourceFile(resRefNum:INTEGER;global:INTEGER):LONGINT;
  249.  INLINE $7014,$A82A;
  250. FUNCTION GetComponentIconSuite( aComponent:Component; VAR iconSuite:Handle):OSErr;
  251.  INLINE $702A,$A82A;
  252.  
  253. {$ENDC} { UsingComponents }
  254.  
  255. {$IFC NOT UsingIncludes}
  256.  END.
  257. {$ENDC}
  258.  
  259.